import request from '../utils/request'

/**
 * 支付通道-广告管理初始化
 * @param {Number} id 代理商id
 */
export function advertInit(id) {
  return request({
    url: '/advert',
    method: 'GET',
    params: { id }
  })
}

/**
 * 广告下一页
 * @param {Number} id 代理商id
 * @param {Number} page 分页页码
 */
export function nextPage(id, page) {
  return request({
    url: '/advert',
    method: 'GET',
    params: { id, page }
  })
}

/**
 * 删除广告
 * @param {Number} id 广告id
 */
export function del(id) {
  return request({
    url: '/advertDel',
    method: 'GET',
    params: { id }
  })
}

/**
 * 广告详情-提交广告
 * @param {Number} id 代理商id
 * @param {Object} date 提交参数
 */
export function addSubmit(id, date) {
  const data = {
    id,
    select: date.type,
    describe: date.describe,
    link: date.link,
    logo: date.logo,
    start_time: date.start_time,
    stop_time: date.stop_time,
    status: date.status
  }

  return request({
    url: '/advertAdd',
    method: 'POST',
    data
  })
}

/**
 * 广告详情页初始化
 */
export function advlistInit() {
  return request({
    url: '/advertAdd',
    method: 'GET'
  })
}

/**
 * 获取广告分类选项
 * @param {number} id 代理商id
 */
export function adverGet(id) {
  return request({
    url: '/edit',
    method: 'GET',
    params: { id }
  })
}

/**
 * 广告修改
 * @param {Number} id 广告id
 * @param {Object} date 广告参数
 */
export function adverEdit(id, date) {
  const data = {
    id,
    select: date.type,
    describe: date.describe,
    link: date.link,
    logo: date.logo,
    start_time: date.start_time,
    stop_time: date.stop_time,
    status: date.status
  }
  return request({
    url: '/edit',
    method: 'POST',
    data
  })
}
